# required versions of other packages
m4_define([glib_required_major], [2])
-m4_define([glib_required_minor], [49])
-m4_define([glib_required_micro], [4])
+m4_define([glib_required_minor], [51])
+m4_define([glib_required_micro], [5])
m4_define([glib_required_version],
[glib_required_major.glib_required_minor.glib_required_micro])
m4_define([glib_min_required_minor],
{
GdkWindowImplWayland *impl;
const char *end;
+ gsize title_length;
+
g_return_if_fail (title != NULL);
if (GDK_WINDOW_DESTROYED (window))
g_free (impl->title);
- g_utf8_validate (title, MAX_WL_BUFFER_SIZE, &end);
- impl->title = g_malloc (end - title + 1);
- memcpy (impl->title, title, end - title);
- impl->title[end - title] = '\0';
+ title_length = MIN (strlen (title), MAX_WL_BUFFER_SIZE);
+ if (g_utf8_validate (title, title_length, &end))
+ {
+ impl->title = g_malloc (end - title + 1);
+ memcpy (impl->title, title, end - title);
+ impl->title[end - title] = '\0';
+ }
+ else
+ {
+ impl->title = g_utf8_make_valid (title, title_length);
+ g_warning ("Invalid utf8 passed to gdk_window_set_title: '%s'", title);
+ }
gdk_wayland_window_sync_title (window);
}